<include file="public@header" />
</head>
<style>
	td input,td select{ width:auto; max-width:180px;}
</style>
<body>
	<php>$page=''</php>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('Aftersale/burial')}">墓区安葬</a></li>
			<li><a href="{:url('orders/chooseGoods')}">商品选购</a></li>
			<li class="active"><a href="{:url('Aftersale/prints')}">交费打证</a></li>
		</ul>
        <form  class="form-horizontal js-ajax-form" method="post" action="{:url('')}">
        	<div class="div_title"><span>客户概览</span></div>
        <div class="control-group1-p div_content">
        	<div class="control-group1">
                <label class="control-label">客户姓名</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.buyer_name}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">持证类型</label>
                <div class="controls">
                    <input type="text" class="form-control" value="身份证" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">证件号码</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.customer_account}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">联系电话</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.buyer_phone}" disabled>
                </div>
            </div>
            <div class="control-group1" style="width:50%;">
                <label class="control-label">联系地址</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.customer_address}" style="width:80%;" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">合同编号</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.contract_sn}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">购买日期</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.gm_start_time}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">打证日期</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.dz_start_time}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">保修状态</label>
                <div class="controls">
                    <input type="text" class="form-control" value="2022年4月21号到期" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">当前状态</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.col_status_name}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">维护期</label>
                <div class="controls">
                    <input type="text" class="form-control" value="未起记" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">墓位编号</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.tomb_num}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">具体位置</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.tomb_region}{$result.tomb_address}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">墓穴规制</label>
                <div class="controls">
                    <input type="text" class="form-control" value="{$result.tomb_regulation_name}" disabled>
                </div>
            </div>
            <div class="control-group1">
                <label class="control-label">单个内穴最大尺寸</label>

                <div class="controls">
                    <input type="text" class="form-control" value="400mm*400mm*400mm" disabled>
                </div>
            </div>
            <!---tab页-->
            <ul class="nav_tabs">
                <li class="active"><a href="javascript:">缴费打证</a></li>
                <li><a href="javascript:">缴费记录</a></li>
            </ul>
            <div class="control-group1-p nav_content">
            	<div class="content_nav">
                	<div class="p_title">
                        <span class="span_title">缴费项目</span>
                    </div>
                    <div class="control-group1-p" style="border:1px solid #e2e2e2; padding-top:20px;margin:0 20px;overflow:hidden; overflow-x:auto;">

                    <table class="table table-hover table-bordered">
                        <thead>
                            <tr>
                                <th>收费项目</th>
                                <th>单位</th>    
                                <th>项目类型</th>  
                                <th>单价</th>                                                                  
                                <th>折扣优惠</th><th>减免金额</th>
                                <th>落葬费</th>
                                <th>应收金额</th>
                            </tr>
                        </thead>
                        <tbody>
                        <foreach name="arr_list" item="vo">
                            <tr >
                            	<td>{$vo.project_name}
                                    <input type="hidden" class="project_name" name="project[{$key}][project_name]" value="{$vo.project_name}"/></td>
                                <td>
                                    <input type="hidden" class="tomb_id" name="project[{$key}][tomb_id]" value="{$result.tomb_id}"/>
                                    <input type="hidden" class="project_unit" name="project[{$key}][project_unit]" value="{$vo.project_unit}"/>
                                    {$vo.project_unit}</td>
                                <td> <input type="hidden" class="project_type"  name="project[{$key}][project_type]" value="{$vo.project_type}"/>
                                    {$vo.project_type}</td>
                                <td>
                                    <input type="hidden" class=""  name="project[{$key}][type]" value="{$vo.type}"/>
                                    <if condition="$vo.type eq 1">
                                    <input type="hidden" class="unit_price"  name="project[{$key}][unit_price]" value="{$vo.unit_price}"/>
                                    <input type="hidden" class="num"  name="project[{$key}][num]"  value="{$vo.num}"/>
                                    <input type="hidden" class="deal_price" name="project[{$key}][deal_price]"  value="{$vo.unit_price*$vo.num}"/>
                                        {$vo.unit_price}*{$vo.num}
                                    <else />
                                        <input type="hidden" class="num"  name="project[{$key}][num]"  value="{$vo.num}"/>
                                        <input type="hidden" class="deal_price" name="project[{$key}][deal_price]"  value="{$vo.unit_price}"/>
                                        <input type="hidden" class="unit_price" name="project[{$key}][unit_price]" value="{$vo.unit_price}"/> {$vo.unit_price}
                                    </if></td>
                                <td>
                                    <if condition="$vo.type eq 1">
                                        <select  name="project[{$key}][discount_rate]"  style="max-width:80px; width:auto;" class="form-control discount_rate">
                                            <for start="0" end="110" step="10" >
                                                <option value="{$i}">{$i}%</option>
                                            </for>
                                        </select>
                                        <else />
                                        <input type="hidden"  name="project[{$key}][discount_rate]" value="" ></input>
                                    </if>

                                </td>
                                <td>
                                    <if condition="$vo.type eq 1">
                                        <input type="text"  name="project[{$key}][free_price]"  class="form-control free_price " style="max-width:80px; width:auto;" value="0"/>

                                        <else />
                                        <input type="hidden"  name="project[{$key}][free_price]" value="0" />
                                    </if>
                                </td>
                                <td>
                                    <if condition="$vo.type eq 0">
                                        <label class="unit_price">{$vo.unit_price}</label>
                                        <else />
                                    </if>
                                </td>
                                <td>
                                    <input type="hidden" class="total_price"  name="project[{$key}][total_price]" value="{$vo.total_price}"/>
                                    <label class="total_price">{$vo.total_price}</label>
                                </td>
                            </tr>
                        </foreach>
                        </tbody>
                    </table>
                    <div class="pagination">{$page}</div>

                  </div>

                  <div class="form-actions">
                      <input type="hidden" class=" " name="buried_id" value="{$buried_id}" >
                      <input type="hidden" class=" " name="order_id" value="{$result.order_id}" >
                      <input type="hidden" class="pay_id"  name="pay_id" value="0"/>
                      <a href="{:url('Aftersale/burial')}" class="btn btn-default"  >返回修改</a>
                      <div class="btn btn-primary" id="check-save">提交</div>
                  </div>
                </div>
            </div>
        </div>
        </form>
    </div>
	<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
	<script type="text/javascript">
	//切换显示
	$(document).on('click','.nav_tabs li',function(){
		$(this).addClass('active').siblings().removeClass('active');
		var index = $(".nav_tabs li").index(this);
		// billtype = index;
		// console.log(index);
		$('.content_nav').eq(index).removeClass("feature").siblings().addClass("feature");
    });

	//计算金额
	$('.discount_rate').change(function () {
	    var unit_price = $(this).parent().parent().find('.unit_price').val();
	    var num = $(this).parent().parent().find('.num').val();

	    var discount_rate = $(this).val();
        var total_price =  (unit_price*num)*((100-discount_rate)/100);
        $(this).parent().parent().find('.total_price').val(parseFloat(total_price).toFixed(2))
        $(this).parent().parent().find('.total_price').text(parseFloat(total_price).toFixed(2))
        $(this).parent().parent().find('.free_price').val(0)
    });

	//计算金额
	$('.free_price').change(function () {

	    $(this).parent().parent().find('.discount_rate').val(0);
	    var unit_price = $(this).parent().parent().find('.unit_price').val();
	    var num = $(this).parent().parent().find('.num').val();
	    var deal_price = $(this).parent().parent().find('.deal_price').val();

        var totalPrice = Number(Number(deal_price.replace(/,/g, "")).toFixed(2)*1 -
            Number($(this).val().replace(/,/g,"")).toFixed(2)*1);


        $(this).parent().parent().find('.total_price').val(parseFloat(totalPrice).toFixed(2))
        $(this).parent().parent().find('.total_price').text(parseFloat(totalPrice).toFixed(2))
    });


	 // 提交订单
    $("#check-save").click(function(){
        $("#otype").val(1);
        $.post($(".form-horizontal").attr('action'), $(".form-horizontal").serialize(), function(result){
            if(result.code == 1){
                layer.alert('提交成功。', {icon: 1, yes: function (index) {
                        layer.close(index);
                        window.location.href = result.url;
                    }})
            } else {
                alert(result.code);
                layer.alert('提交失败！', {icon: 3})
            }
        }, 'json');
    });

    </script>


</body>
</html>